<template>
  <div class="toutiao">
    <div class="img-wrapper">
      <img src="https://p3-sign.toutiaoimg.com/tos-cn-i-axegupay5k/e62fecf27b6046d0a07b2889ae6f4f7f~tplv-tt-large.image?_iz=30575&lk3s=06827d14&x-expires=1717557855&x-signature=JHFdAX6jm8YaQQYNQlxNqQBtuhI%3D" alt="">
    </div>
    <div class="content-wrapper">
      <div class="item" v-for="h of headlineNews">
        <div class="left">
          <img v-bind:src="h.thumbnail_pic_s" alt="">
        </div>
        <div class="right">
          <h1 class="title">{{ h.title }}</h1>
          <div class="text-wrapper">
            <span class="category-text">{{ h.category }}</span>
            <span class="date-text">{{ h.date }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "Headline",
  data() {
    return {
      headlineNews: []
    }
  },
  methods: {
    _initheadlineNews() {
      // 发送ajax请求拿新闻数据
      axios.get('/juheNews',{
        params: {key: "f9a452b189229b611f71d0a4d1e326e6"}
      }).then(res => {
        if(res.data.error_code === 0) {
          this.headlineNews = res.data.result.data;
          console.log(this.headlineNews)
        } else {
          alert('请求失败')
        }
      })
    }
  },
  created() {
    this._initheadlineNews()
  }
}
</script>

<style scoped lang="stylus">
.toutiao
  margin-top 10px
  .img-wrapper
    width 100%
    height 80px
    img
      width 100%
      height 100%
  .content-wrapper
    margin-top 20px
    .item
      display flex
      width 100%
      height 70px
      padding 4px 0
      border-bottom 1px dotted #2d3a4b
      .left
        width 90px
        height 70px
        img
          width 90px
          height 70px
      .right
        display flex
        flex-wrap wrap
        align-content space-between
        box-sizing border-box
        padding-left 15px
        padding-bottom 15px
        .text-wrapper
          margin-left 20px
</style>